<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>6_1_1-3-HTML更新或渲染</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

  <div id="Application">
    <sub-com> {{content}} </sub-com>
    <button @click="change">测试</button>
  </div>

  <script>
    const sub = {
      beforeCreate() {
        console.log("组件即将创建前");
      },

      created() {
        console.log("组件创建完成");
      },

      renderTracked(event) {
        console.log("虚拟DOM重建渲染时调用");
      },

      renderTriggered(event) {
        console.log("虚拟DOM被触发渲染时调用");
      },
      template: `<div><slot></slot></div>`,
    };

    const App = Vue.createApp({
      data() {
        return {
          content: 0,
        };
      },
      methods: {
        change() {
          this.content += 1;
        },
      },
    });
    App.component("sub-com", sub);

    App.mount("#Application"); //将Vue组件绑定到页面上id为Application的元素上。
  </script>
</body>

</html>